package com.sooncode.project.focusservice.service;

import com.sooncode.project.core.finder.Finder;
import com.sooncode.project.core.finder.Page;
import com.sooncode.project.core.finder.Sort;
import com.sooncode.project.focusservice._.base.BaseService;
import com.sooncode.project.focusservice.model.SensoryScore;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class SensoryScoreService extends BaseService<SensoryScore> {
    @Override
    public Page<SensoryScore> getPageList(int pageSize, int pageIndex, Map<String,Object> map){
        if(map.containsKey("no") && !StringUtils.isEmpty(map.get("no").toString())) map.put("no",Integer.parseInt(map.get("no").toString()));
        if(map.containsKey("age") && !StringUtils.isEmpty(map.get("age").toString())) map.put("age",Integer.parseInt(map.get("age").toString()));
        return new Finder<SensoryScore>(SensoryScore.class)
                .byMap(map)
                .page(pageSize, pageIndex, Sort.DESC("no").Desc("age").Desc("min"));
    }
    public boolean copy(String id){
        SensoryScore sensoryScore=getById(id);
        sensoryScore.copy();
        return true;
    }
}

